package Year22_Month06.day25;

public class 二叉搜索树转化为累加树 {
    int num;
    public TreeNode convertBST(TreeNode root) {
        if(root == null) return null;
        solve(root);
        return root;
    }

    public  void solve(TreeNode root){
        if(root == null) return;
        solve(root.right);
        root.val += num;
        num = root.val;
        solve(root.left);
    }
}
